package com.konne.nightmare.FastPublicOpinion.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.SizeUtils;
import com.konne.nightmare.FastPublicOpinion.R;
import com.konne.nightmare.FastPublicOpinion.base.BaseDialog;

/**
 * Create by ws.
 * on Data:2022/1/25  Time:下午 6:11.
 * description: ** .
 */
public class CGroupManagerDialog extends Dialog implements View.OnClickListener {
    private CGroupManagerListener cGroupManagerListener;
    public CGroupManagerDialog(@NonNull Context context) {
        super(context);
    }

    public CGroupManagerDialog setcGroupManagerListener(CGroupManagerListener cGroupManagerListener) {
        this.cGroupManagerListener = cGroupManagerListener;
        return this;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_cgroup);
        Window dialogWindow = getWindow();
        dialogWindow.setBackgroundDrawableResource(android.R.color.transparent);
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        lp.width = ViewGroup.LayoutParams.MATCH_PARENT;
        lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        dialogWindow.setAttributes(lp);
        dialogWindow.getDecorView().setPadding(SizeUtils.dp2px(10), 0, SizeUtils.dp2px(10), SizeUtils.dp2px(10));
        dialogWindow.setGravity(Gravity.BOTTOM);
        findViewById(R.id.stv1).setOnClickListener(this::onClick);
        findViewById(R.id.stv2).setOnClickListener(this::onClick);

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.stv1:
                if(cGroupManagerListener!=null){
                    cGroupManagerListener.fun(0);
                }
                break;
            case R.id.stv2:
                if(cGroupManagerListener!=null){
                    cGroupManagerListener.fun(1);
                }
                break;
        }
        dismiss();
    }
    public interface CGroupManagerListener{
        void fun(int type);
    }
}
